package com.shijie99.russ.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.shijie99.russ.pojo.User;
import com.shijie99.russ.service.IUserService;

@Controller
@RequestMapping("/user")
public class UserController {
	@Autowired
	private IUserService userservice;
	private static Logger logger = Logger.getLogger(UserController.class);

	@RequestMapping("/showUser")
	public String show(HttpServletRequest request, HttpServletResponse response, Model model) {
		int userId = Integer.parseInt(request.getParameter("id"));
		User user = userservice.getUserById(userId);
		model.addAttribute("user", user);
		logger.info(JSON.toJSONString(user));
		return "login";

	}

}
